package controllers;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;

import systems.ConfigSystem;
import entities.SiteConfig;

public class SearchServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response) 
		throws IOException, ServletException {
		
		SiteConfig config = ConfigSystem.getConfigs();	
		
		String name = (String) request.getParameter("q");
		
		if( name == null )
		{
			response.sendRedirect("/");
			return;
		}
		
		response.sendRedirect("/gsearch?cx=" + config.getCxGoogleSearch() + "&cof=FORID%3A10&ie=UTF-8&q=" + name + "&sa=Search");
		return;
		
	}
}
